var deviceone = require("deviceone");
var nf = deviceone.sm("do_Notification");
var httpSilence = require("helper/httpSilence");
var userUrl = require("url/user");
var cacher = deviceone.sm("do_DataCache");
var userHelper = require("helper/user");
/** 访问社区id */
var userValueId = "userValueId";
module.exports.userValueId = function() {
	if (arguments.length == 0) {
		if (cacher.hasData(userValueId)) {
			var value = cacher.loadData(userValueId);
			if (!value || value == null || value === "undefined") {
				return "";
			}
			return value;
		}
	}
	if (arguments[0] === "") {
		cacher.removeData(userValueId);
		return;
	}
	cacher.saveData(userValueId, "" + arguments[0]);
};
/**
 * checkXY 检查uservalue的x、y
 */
module.exports.checkXY = function(trueBack, falseBack) {
	if (null == userHelper.loginToken() || '' == userHelper.loginToken()) {
		nf.toast("请先登录。")
		return;
	}
	httpSilence.post(userUrl.url.value.checkXY, {}, function(data) {
		if (data.userValue && null != data.userValue.x && null != data.userValue.y
				&& 0 != data.userValue.x && 0 != data.userValue.y) {
			if (trueBack && trueBack != null && trueBack !== "undefined") {
				trueBack(data);
			}
		} else {
			if (falseBack && falseBack != null && falseBack !== "undefined") {
				falseBack(data)
			}
		}
	});
};
